package com.smile.config.entity.base;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@MappedSuperclass
@Access(AccessType.FIELD)
@Setter
@Getter
@EqualsAndHashCode(callSuper = true)
@EntityListeners(AuditingEntityListener.class)
public class SuperBaseEntity extends SuperIdEntity {

  @Column(name="create_user_id", length=32,updatable=false,nullable=true)
  @CreatedBy()
  private Long createUserId;

  @Temporal(TemporalType.TIMESTAMP)
  @Column(name="create_time",updatable=false,nullable=true)
  @CreatedDate
  private Date createDatetime;

  @Column(name="last_update_user_id", length=32,nullable=true)
  @LastModifiedBy()
  private Long lastUpdateUserId;

  @Temporal(TemporalType.TIMESTAMP)
  @Column(name="last_update_time" , nullable=true)
  @LastModifiedDate
  private Date lastUpdateDatetime;

  @Version
  @Column(name = "version")
  private long version;
}
